Name: Portal System Addon: Top Referrers v1.2

Last modified: 03/24/2008

Description:
This mod will add a "Top 10 Referrer" block to your portal.
This mod is dependent on the XMB Portal System v2.4 And the Referrals v1.5 mod (Written by Adam Clarke).

Compatibility: XMB v1.9.5 (Final)

Tested On: XMB 1.9.5 (Final)

Code Developed By: Adam Clarke (http://www.adam-clarke.co.uk)

MOD History: V1.0 (06/08/2005 @ 01:10) - Initial Release.
                         V1.1 (06/08/2005 @ 02:55) - Added instructions for OLD referral mod.
                         V1.2 (19/08/2005 @ 19:05) - Replaced 'xmb_' with '$table_'.
                         V1.2 (05/16/2006 @ 01:17) - Updated for 1.9.5 by: WormHole @ XMB Garage.

License Note: This mod is released under the GPL License.

Note: Backup all affected files, templates & database's.

Affected Files: portal.php, lang/English.lang.php

Affected Templates: NONE




====================================================================================================
STEP 1: Edit File 'portal.php'

Find Code:
---------------------------------------------------------------------------------------------------
'portal_quick_reg_password',
'portal_quick_reg'
---------------------------------------------------------------------------------------------------

Replace Code With:
---------------------------------------------------------------------------------------------------
'portal_quick_reg_password',
'portal_quick_reg',
'portal_top_referrers'
---------------------------------------------------------------------------------------------------

Find Code:
----------------------------------------------------------------------------------------------------
$sql = $db->query("SELECT p.*, t.* FROM $table_portal_templates p LEFT JOIN $table_templates t ON t.name = p.name WHERE p.status = 'on' ORDER BY p.displayorder ASC  LIMIT 0 , 30");
----------------------------------------------------------------------------------------------------

Add Code Above:
----------------------------------------------------------------------------------------------------

// Top 10 Referrers Mod Begin
$top_referrers = array();
$query = $db->query("SELECT count(m.uid) as count, m.username FROM $table_members r LEFT JOIN $table_members m ON r.referredby = m.uid WHERE r.referredby > 0 GROUP BY r.referredby ORDER BY count DESC LIMIT 0, 10");
while ($top_referrer = $db->fetch_array($query)) {
    $top_referrers[] = "<tr>\n<td class=\"tablerow\" bgcolor=\"$altbg2\"><a href=\"./member.php?action=viewpro&amp;member=".rawurlencode($top_referrer['username'])."\">$top_referrer[username]</a></td><td class=\"tablerow\" bgcolor=\"$altbg1\">$top_referrer[count]</td>\n</tr>";
}
$top_referrers = implode("\n", $top_referrers);
// Top 10 Referrers Mod End

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 1: Edit File 'English.portal.php'

Find Code:
----------------------------------------------------------------------------------------------------
?>
----------------------------------------------------------------------------------------------------

Add Code Above:
----------------------------------------------------------------------------------------------------

// Top 10 Referrers Mod Begin
$lang['top_referrers'] = "&raquo; Top 10 Referrers";
// Top 10 Referrers Mod End

----------------------------------------------------------------------------------------------------
====================================================================================================




====================================================================================================
STEP 3: Create New Portal Block 'portal_top_referrers'

Add Code And Submit:
----------------------------------------------------------------------------------------------------

<table cellspacing="0" cellpadding="0" border="0" width="100%" bgcolor="$bordercolor">
<tr>
<td>
<table border="0" cellspacing="$borderwidth" cellpadding="$tablespace" width="100%">
<tr>
<td class="category" colspan="2"><strong><font color="$cattext">$lang[top_referrers]</font></strong></td>
$top_referrers
</table>
</td>
</tr>
</table>

----------------------------------------------------------------------------------------------------
====================================================================================================